#include "ConData.h"
#include "ChildProcessRecorder.h"

#pragma comment(lib, "User32.lib")

namespace Con
{
	namespace detail
	{
		ConData::ConData(DWORD pid, IO* io, ChildProcessRecorder& recorder, HWND hwnd)
			: pid(pid), io(io), recorder(recorder), hwnd(hwnd)
		{
		}

		// remove the entry with the recorder when this console data
		// is destroyed
		ConData::~ConData()
		{
			recorder.Remove(pid);
		}

		DWORD ConData::GetPid() const
		{
			return pid;
		}

		void ConData::BringToFront() const
		{
			SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
		}

		void ConData::SendToBack() const
		{
			SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
		}

		IO* ConData::GetStreamPointer() const
		{
			return io.get();
		}
	}
}
